package gui;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;

import body.IArea;
import body.IPainting;


/**
 * 鼠标控制中心
 *
 */
public class MouseCentor implements IPainting,IArea{
	
	public Point p1 = new Point();
	
	public Point p2 = new Point();
	
	@Override
	public void draw(Graphics g) {
		
			int x = Math.min(p1.x, p2.x);
			int y = Math.min(p1.y, p2.y);;
			int width = Math.abs(p1.x - p2.x);
			int height = Math.abs(p1.y - p2.y);
			g.setColor(Color.GREEN);
			g.drawRect(x, y, width, height);
			
		
//		g.drawOval(x, y, width, height);
	}
	
	
	
	public void clear(){
		p1.setLocation(0, 0);
		p2.setLocation(0, 0);
	}



	@Override
	public Rectangle getRectangle() {
		int x = Math.min(p1.x, p2.x);
		int y = Math.min(p1.y, p2.y);
		int width = Math.abs(p1.x - p2.x);
		int height = Math.abs(p1.y - p2.y);
		return new Rectangle(x, y, width, height);
	}


	
	
	
}
